<!--
 * Description: FD待接收驳回页面
 * Company: 联宝（合肥）电子科技有限公司
 * Author: Jian.Yang
 * Date: 2021/01/04 14:08
-->

<template>
  <div>
    <!--数据表单-->
    <el-form label-width="100px" :model="formData" size="mini">
      <el-row>
        <!--FD编号-->
        <el-col :span="24">
          <el-form-item :label="$t('FdData.fdId')">
            <span>{{ formData.fdId }}</span>
          </el-form-item>
        </el-col>

        <!--FD名称-->
        <el-col :span="24">
          <el-form-item :label="$t('FdData.version')">
            <span>{{ formData.version }}</span>
          </el-form-item>
        </el-col>

        <!--FD名称-->
        <el-col :span="24">
          <el-form-item :label="$t('FdData.fdName')">
            <span>{{ formData.fdName }}</span>
          </el-form-item>
        </el-col>

        <!--驳回原因-->
        <el-col :span="24">
          <el-form-item :label="$t('FdData.rejectReason')">
            <el-input v-model="formData.reason" clearable :rows="5" type="textarea" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <span style="display: block;text-align: center;margin-top: 5px">
      <!--取消按钮-->
      <el-button size="medium" @click="cancel">{{ $t('button.cancel') }}</el-button>
      <!--保存按钮-->
      <el-button :loading="isRequesting" size="medium" type="primary" @click="save">
        {{ $t('button.save') }}
      </el-button>
    </span>
  </div>
</template>

<script>
import { fdReject } from '@/api/serverbom/fd'

export default {
  name: 'ServerReceiveReject',
  props: {
    inputData: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      // 正在查询
      isRequesting: false,
      formData: {}
    }
  },
  mounted() {
    this.pageDataInit()
  },
  methods: {
    pageDataInit() {
      this.formData = this.$deepCopy(this.inputData)
    },
    async save() {
      try {
        await this.$confirmBox(this.$t('button.save'), 'success')
        this.isRequesting = true
        await fdReject(this.formData, { msgSuccess: true, msgError: true })
        this.$emit('save')
      } catch (error) {
        console.log(error)
      } finally {
        this.isRequesting = false
      }
    },
    cancel() {
      this.$emit('cancel')
    }
  }
}
</script>

<style scoped>
.el-form-item__content span {
  margin-left: 5px;
  color: blue;
}
</style>
